<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="d" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>主页</title>
    <!-- 1. 导入CSS的全局样式 -->
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery导入，建议使用1.9以上的版本 -->
    <script src="${pageContext.request.contextPath}/js/jquery-2.1.0.min.js"></script>
    <!-- 3. 导入bootstrap的js文件 -->
    <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
    <div style="margin: 5px">
        <a class="btn btn-primary"
           href="${pageContext.request.contextPath}/UserBlog/Blog?id=${requestScope.blog}">返回</a>
    </div>
    <p style="text-align: center;" class="bg-info">---</p>
    <br>

    <!-- 显示的信息框 -->
    <c:if test="${requestScope.author_msg!=null}">
        <div class="alert alert-warning alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert">
                <span>&times;</span></button>
            <strong>${requestScope.author_msg}</strong>
        </div>
    </c:if>
    <div>
        <p style="float: left;">

        <table class="table table-hover">
            <tr id="backLast">
                <th colspan="2">返回上一级</th>
            </tr>
            <tr>
                <th>#</th>
                <th>标签名</th>
            </tr>
            <c:if test="${requestScope.labelPage!=null}">
                <c:forEach items="${requestScope.labelPage}" var="label" varStatus="s">
                    <tr>
                        <td>${s.count}</td>
                        <td>
                            <a href="${pageContext.request.contextPath}/UserBlog/authorHome?labelPrior=${label.id}&id=${requestScope.author_user.id}&bid=${requestScope.blog}">${label.content}</a>
                        </td>
                    </tr>
                </c:forEach>
            </c:if>
            <c:if test="${requestScope.labelPage==null}">
                <tr>
                    <td colspan="2">没有子标签了哦</td>
                </tr>
            </c:if>
        </table>

        </p>
        <p align="right">
            <img src="${pageContext.request.contextPath}/headImg/${requestScope.author_user.path}"
                 class="img-thumbnail" width="150" height="150">
            <br><b>${requestScope.author_user.username}&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp</b><br>
            <%--展示关注的--%>
            <d:if test="${requestScope.author_user.id!=sessionScope.user.id}">
                <c:if test="${requestScope.author_flag}">
                    <a style="align :center;margin: 5px" class="btn btn-primary"
                       href="${pageContext.request.contextPath}/UserFriend/userFriend?status=0&aid=${requestScope.author_user.id}&bid=${requestScope.blog}">取消关注</a>
                </c:if>
                <c:if test="${!requestScope.author_flag}">
                    <a style="align :center;margin: 5px" class="btn btn-default"
                       href="${pageContext.request.contextPath}/UserFriend/userFriend?status=1&aid=${requestScope.author_user.id}&bid=${requestScope.blog}">关注</a>
                </c:if>
            </d:if>
            关注数 : ${requestScope.author_count}
        </p>
    </div>
    <p style="text-align: center;" class="bg-info">---</p>


    <%--展示用户的文章--%>
    <c:forEach items="${requestScope.blogPageBean.list}" var="blog" varStatus="s">
        <a href="${pageContext.request.contextPath}/UserBlog/Blog?id=${blog.id}">
            <h4>${blog.title}</h4></a>
        <blockquote>
            <c:if test="${blog.content.length()>=20}">
                <p>${blog.content.substring(0,20)}...</p>
            </c:if>
            <c:if test="${blog.content.length()<20}">
                <p>${blog.content}</p>
            </c:if>
        </blockquote>
    </c:forEach>


    <%--下面这里是分页的数据--%>
    <div>
        <nav aria-label="Page navigation">
            <ul class="pagination">
                <%--这个li就是代表上一页的了--%>
                <c:if test="${requestScope.blogPageBean.currentPage==1}">
                <li class="disabled">
                        <%--这里是一个禁用,但页码为1的时候不让用--%>
                    </c:if>
                    <c:if test="${requestScope.blogPageBean.currentPage!=1}">
                <li>
                    </c:if>
                    <a href="${pageContext.request.contextPath}/UserBlog/authorHome?labelPrior=${requestScope.labelPrior}&currentPage=${requestScope.blogPageBean.currentPage-1}&rows=5&id=${requestScope.author_user.id}&bid=${requestScope.blog}"
                       aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                    </a>
                </li>


                <c:forEach begin="1" end="${requestScope.blogPageBean.totalPage}" var="i">
                    <%--上面这个显示的是激活状态
                    下面显示的是未激活状态 --%>
                    <c:if test="${requestScope.blogPageBean.currentPage==i}">
                        <li class="active"><a
                                href="${pageContext.request.contextPath}/UserBlog/authorHome?labelPrior=${requestScope.labelPrior}&currentPage=${i}&rows=5&id=${requestScope.author_user.id}&bid=${requestScope.blog}">${i}</a>
                        </li>
                    </c:if>
                    <c:if test="${requestScope.blogPageBean.currentPage!=i}">
                        <li>
                            <a href="${pageContext.request.contextPath}/UserBlog/authorHome?labelPrior=${requestScope.labelPrior}&currentPage=${i}&rows=5&id=${requestScope.author_user.id}&bid=${requestScope.blog}">${i}</a>
                        </li>
                    </c:if>
                </c:forEach>

                <c:if test="${requestScope.blogPageBean.currentPage==requestScope.blogPageBean.totalPage}">
                <li class="disabled">
                    </c:if>
                    <c:if test="${requestScope.blogPageBean.currentPage!=requestScope.blogPageBean.totalPage}">
                <li>
                    </c:if>
                    <a href="${pageContext.request.contextPath}/UserBlog/authorHome?labelPrior=${requestScope.labelPrior}&currentPage=${requestScope.blogPageBean.currentPage+1}&rows=5&id=${requestScope.author_user.id}&bid=${requestScope.blog}"
                       aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>

                <span style="font-size: 25px;margin: 5px">
                共${requestScope.blogPageBean.totalCount}条记录,共${requestScope.blogPageBean.totalPage}页
                </span>
            </ul>
        </nav>
    </div>
</div>
<script>
    document.getElementById("backLast").onclick = function () {
        if (${requestScope.labelPrior!=null}) {
            window.history.back(-1);
        }
    }
</script>
</body>
</html>
